﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucQuanLyAlbumAnh.ascx.cs" Inherits="CuoiHoi.Admin.ucQuanLyAlbumAnh" %>
<h3>Quản lý Album Ảnh</h3>
<div class="table-responsive">
    <div class="box-title">
    </div>

    <div class="box-content">

        <div class="row">
            <label class="col-md-2">Tên Album:</label>
            <div class="col-md-8">
                <asp:DropDownList ID="cbbTenAlbum" CssClass="form-control" runat="server" AutoPostBack="true"
                    OnTextChanged="cbbTenAlbum_TextChanged">
                </asp:DropDownList>
                <asp:Label ID="Label1" runat="server" Text="Label" CssClass="hide"></asp:Label>
            </div>
        </div>

        <br/>
             <div class="KhungHinh">
                 <asp:Repeater ID="Repeater1" runat="server">
                     <ItemTemplate>
                         <div class="avata" style="float: left; width: 160px; height: 185px; text-align: center">
                             <img class="KhungHinhXoa" src="../img/delete.jpg" data-id='<%# Eval("idHinhAnh") %>'
                                 alt="Xóa" />
                             <img src='../images/<%#Eval("DuongDanHinh") %>' alt="Alternate Text" height="150px" width="150px"
                                 style="margin: 10px 10px; float: left" />
                         </div>
                     </ItemTemplate>
                 </asp:Repeater>
             </div>
        <div style="overflow: hidden;" class="phantrang">
            <asp:Repeater ID="rptPages" runat="server"
                OnItemCommand="rptPages_ItemCommand1">
                <ItemTemplate>
                    <asp:LinkButton ID="btnPage"
                        Style="padding: 1px 3px; margin: 1px; background: #ccc; border: solid 1px #666;
                        font: 8pt tahoma;"
                        CommandName="Page" CommandArgument="<%# Container.DataItem %>"
                        runat="server"><%# Container.DataItem %>
                    </asp:LinkButton>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </div>

      <asp:Button ID="btnXoaAlbum" runat="server" Text="Xóa album" class="btn btn-primary" OnClick="btnXoaAlbum_Click" />
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $('.KhungHinhXoa').click(function () {
            var result = confirm('Bạn có muốn xóa?');

            if (!result) return;

            var idHinhAnh = $(this).data('id');
 
            $.ajax({
                type: "POST",   
                url: "Default.aspx/XoaHinhAnh",
                data: '{idHinhAnh :"' + idHinhAnh + '"}',
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (response) {
                    //alert(response.d)
                },
                failure: function (response) {
                    alert('Không kết nối được!');
                },
                error: function (response) {
                    alert("Lỗi");
                    //alert(MaHV + ' ' + RoleDN)
                }
            });

            $(this).parent().remove();
        });
    });
</script>

